package org.despair2D.utils 
{
	import org.despair2D.core.ITickListener;
	import org.despair2D.core.ProcessManager;
	import org.despair2D.debug.Logger;
	import org.despair2D.utils.core.TimerManagerBase;
	
	import org.despair2D.core.ns_despair;
	use namespace ns_despair;
	
	
public class TickTimerManager extends TimerManagerBase implements ITickListener
{
	
	
	private static var m_instance:TickTimerManager
	public static function getInstance() : TickTimerManager
	{
		return m_instance ||= new TickTimerManager()
	}
	

	/**
	 * 自动开始
	 */
	override ns_despair function checkAutoStart():void
	{
		if (m_runningLength == 0 && m_joiningLength == 0)
		{
			ProcessManager.instance.addTickListener(this, ProcessManager.TIMER);
			m_systemTime = 0;
			
			Logger.reportMessage(this, '定时器(tick)，开始');
		}

	}
	
	
	/**
	 * @inheritDoc
	 * 自动停止
	 */
	override protected function _checkAutoStop():void
	{
		if (m_runningLength == 0 && m_joiningLength == 0)
		{
			ProcessManager.instance.removeTickListener(this);
			m_systemTime = 0;
			
			Logger.reportMessage(this, '定时器(tick)，全部结束');
		}
	}
}

}